<template>

	
		<view class="index-page" style="background-color: white;">
			<view :style="{ paddingTop: px + 'px' }"></view>
			<view class="topbackground" >
				<view class="header" >
					<view class="Narbar_bo">
						<view @click="back"><u-icon name="arrow-left"></u-icon></view>
						<view class="title" size="19px">检测项目</view>
						
						<view></view>
					</view>
				</view>
				<view class="box1" v-for="(item,index) in exaList">
					<view class="namePhy">体检人：{{item.examinerInfo.name}}</view>
					<view class="phyInfo" style="padding:24rpx 0 0 28rpx;">
						<view class="setMNa">
							<text class="text1">体检套餐</text>
							<text class="text2">{{item.meal.setMealName}}</text>
						</view>
						<view class="setMTi" style="padding-top:18rpx;">
							<text class="text1">体检时间</text>
							<text class="text2">{{item.date}}- {{item.startTime}}-{{item.endTime}}</text>
		
						</view>
						<view class="setMNu" style="padding-top:18rpx;">
							<text class="text1">订单编号</text>
							<text class="text2">{{item.orderNo}}</text>
						</view>
					</view>
					<view class="result" style="display:flex; align-items: center;">
						<view class="result1" :style="{color:item.status==2? '#73eb02' : '#EB5432'}">
							{{item.status==2? '已出结果' : '待出结果'}}
						</view>
						<view class="right2" :style="{background: item.status==2? '#159DFF' : '#a8a8a8'}" @click="appointMent1(item)">
							<view class="textRe">
								查看报告
							</view>
						</view>
		
					</view>
		
					<view class="result" style="display:flex;" v-if="item.result==0">
						<view class="result1" style="color: #EB5432;">
							{{item.restultStatus}}
						</view>
						<view class="right2" @click="appointMent0(item)" style="background: #E0E0E0;color: #FFFFFF;">
							<view class="textRe">
								 {{item.status == 2 ? '查看报告' : '等待结果'}}
							</view>
						</view>
		
					</view>
				</view>
			 <image  v-if="!exaList.length" src="../../static/images2/empty.png"  style=" position: absolute; left: 50%; transform: translateX(-50%); width: 400rpx; height: 400rpx;"></image>
			</view>
		</view>
</template>

<script>
	import order from "@/api/order.js"
	export default {
		name: "Index",
		components: {},
		data() {
			return {
				exaList: [],
				heightConfig: {},
				px:"",
				orderNo:""
			};
		},
		onLoad(query) {
			let _this = this
			uni.getSystemInfo({
				success(res) {
					_this.heightConfig.navBarPaddingTop = res.statusBarHeight // 单位：px
					 _this.px = _this.heightConfig.navBarPaddingTop = res.statusBarHeight 
					console.log(res.statusBarHeight,"单位")
				} 
			})
			console.log(query,"查询参数")
			this.orderNo = query.orderNo;
			this.getOrderListData(this.orderNo)
		},
		onShow() {

		},
		onReady() {},
		methods: {
			appointMent1(item) {  
			//	if(item.status!=2) return
				uni.navigateTo({
					// url: "/subPages/hosPacDetails/hosPacDetails",
					url: `/subPages/reportDetail/reportDetail?exameInfo=${encodeURIComponent(JSON.stringify(item))}`,
				})
			},
			handlerData(data) {
				console.log(data)
				data.rows.forEach((item, index) => {
					if (item.status == 2) {
						item['isOver'] = true
						this.exaList.push(item)
					} else {
						item['isOver'] = false
						this.exaList.push(item)
					}
				})
			},
			back() {
				uni.navigateBack({
					delta: 1, //返回层数，2则上上页
				})
			}, //0未付款 1已付款 2已完成 3已退款 4已预约 5已关闭 6完成中
			getOrderListData(orderdata) {
				if(orderdata){
					const overOrder = order.getOrderList({
						status: 2,
						orderNo:orderdata
					})
					
					const overIng = order.getOrderList({
						status: 7,
						orderNo:orderdata
					})
					
					Promise.all([overOrder]).then(([ongoingOrders]) => {
					//	this.handlerData(completedOrders)
						//console.log("overOrder", completedOrders)
						this.handlerData(ongoingOrders)
					
					})
				}else{
					
					const overOrder = order.getOrderList({
						status: 2,
					})
					
					
					
					Promise.all([overOrder]).then(([completedOrders]) => {
						//this.handlerData(completedOrders)
						console.log("overOrder", completedOrders)
						this.handlerData(completedOrders)
					  
					})
					
				}
				

			}
		},
		mounted() {
			//获取已完成或者完成中的订单
			

		}
	};
</script>

<style lang="less" scoped>
	.topbackground {
		width: 100%;
		height: 338rpx;
		width: 750rpx;
		height: 1624rpx;
		background: white;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.index-page {
		width: 750rpx;
		height: 100%;
		overflow-y: scroll;
		background: white;
		box-sizing: border-box;

		.Narbar_bo {
			width: 100%;
			height: 35px;
			display: flex;
		
			padding: 0 28rpx;
			justify-content: space-between;
			align-items: center;

			.title {
				font-size: 18px;
				font-weight: 600;
			}
		}
	}

	.avator {
		margin: 42rpx 0 0 52rpx;
		width: 90rpx;
		height: 90rpx;
		background: #C1D0FF;
		border-radius: 98rpx 98rpx 98rpx 98rpx;
	}

	.namePhy {
		white-space: nowrap;
		padding: 20rpx 0 30rpx 34rpx;

		width: 168rpx;
		height: 40rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #000000;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.text1 {
		padding: 42rpx 0 0 15rpx;
		width: 112rpx;
		height: 40rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #777777;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.text2 {
		padding-left: 36rpx;
		white-space: nowrap;
		width: 204rpx;
		height: 40rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 20rpx;
		color: #000000;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.box1 {
		margin: 16rpx 0 0 32rpx;
		// border:1rpx solid black;
		width: 686rpx;
		height: 358rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.phyInfo {
		margin: 20rpx 0 0 28rpx;
		width: 632rpx;
		height: 204rpx;
		background: #F8FCFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.result1 {
		margin: 14rpx 0 0 34rpx;
		width: 99rpx;
		height: 34rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 24rpx;
		color: #51DD5A;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.right2 {
		margin: 15rpx 0 0 388rpx;
		// margin: 42rpx 0 0 0;
		width: 146rpx;
		height: 52rpx;
		background: #159DFF;
		border-radius: 74rpx 74rpx 74rpx 74rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.textRe {
		// text-overflow: ellipsis;
		// white-space: nowrap;
		width: 104rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #FFFFFF;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}
</style>